package com.seadragon.app.dms.util;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.code.geocoder.Geocoder;
import com.google.code.geocoder.GeocoderRequestBuilder;
import com.google.code.geocoder.model.GeocodeResponse;
import com.google.code.geocoder.model.GeocoderRequest;
import com.google.code.geocoder.model.GeocoderResult;
import com.google.code.geocoder.model.GeocoderStatus;
import com.seadragon.app.dms.model.Address;

public class GeocodingUtil {
	private static final Geocoder geocoder = new Geocoder();
	private static Logger logger = LoggerFactory.getLogger(GeocodingUtil.class);
	public static void geocode(Address address){
		GeocoderRequest request = new GeocoderRequestBuilder().setAddress(address.toString()).setLanguage("en").getGeocoderRequest();
		GeocodeResponse response = geocoder.geocode(request);
		if(response.getStatus() == GeocoderStatus.OK){
			List<GeocoderResult> results = response.getResults();
			for(GeocoderResult result : results){
//				result.
				logger.info(result.toString());
			}
			logger.info(response.toString());
		}
	}
}
